stroka= input()
stack = []
res = True

for i in stroka:
    if i in "([{":
        stack.append(i)
    elif i in ")]}":
        if len(stack) == 0:
            res = False
            break

        el = stack.pop()
        if el == '(' and i == ')':
            continue
        if el == '[' and i == ']':
            continue
        if el == '{' and i == '}':
            continue

        res  = False
        break

if res and len(stack) == 0: 
    print(True)
else:
    print(False)
